<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <title>管理后台</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <!-- 新 Bootstrap 核心 CSS 文件 -->
        <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">

        <!-- 可选的Bootstrap主题文件（一般不用引入） -->
        <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

        <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
        <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>

        <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
        <script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
        <link href="Public/admin/css/dashboard.css" rel="stylesheet">

        <link rel="stylesheet" href="Public/Editor/themes/default/default.css" />
		<script charset="utf-8" src="Public/Editor/kindeditor-all-min.js"></script>
		<script charset="utf-8" src="Public/Editor/lang/zh-CN.js"></script>
    </head>
    <body>
        <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">管理后台</a>
        </div>
        <include file="./Public/admin/navbar.html" keywords="1" />
          
      </div>
    </nav>

    <div class="container-fluid">
      <div class="row">
        <include file="./Public/admin/menu.html" keywords="2" />
        <!--正式内容开始-->
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
          
          <h2 class="sub-header">文章管理</h2>
          <form action="?m=Center&c=Admin&a=article" method="POST">
              <present name="Think.get.id" >
                  <input type="hidden" name="action" value="amend" />
                  <input type="hidden" name="id" value="{$Think.get.id}" />
                  <else/>
                  <input type="hidden" name="action" value="add" />
              </present>
              
              <input type="hidden" name="c1" value="0" />
              <input type="hidden" name="c2" value="0" />
              <input type="hidden" name="c3" value="0" />
              <input type="hidden" name="type" value="0" />
            <div class="form-group">
              <label for="exampleInputEmail1">文章标题</label>
              <input type="text" class="form-control" name="title" placeholder="文章标题内容" value="<present name="Think.get.id" >{$article.title}</present>">
            </div>
            
              <div class="form-group">
              <label for="exampleInputEmail1">活动类型</label>
              <div class="row">
  <div class="col-lg-6">
    <div class="input-group">
      <div class="input-group-btn">
          <button type="button" class="btn btn-default dropdown-toggle selectC1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><present name="Think.get.id" >{$article.c1name}<else/>选择分类</present> <span class="caret"></span></button>
        <ul class="dropdown-menu">
            <foreach name="c1" item="vo">
                <li><a href="javascript:c1f({$vo.id},'{$vo.channel_name}')">{$vo.channel_name}</a></li>
            </foreach>
        </ul>
      </div><!-- /btn-group -->
      <input type="text" class="form-control selectInputC1" aria-label="...">
    </div><!-- /input-group -->
  </div><!-- /.col-lg-6 -->
  </div><!-- /.row -->
              </div>
              
              
              <div class="form-group">
              <label for="exampleInputEmail1">行业</label>
              <div class="row">
  <div class="col-lg-6">
    <div class="input-group">
      <div class="input-group-btn">
          <button type="button" class="btn btn-default dropdown-toggle selectC2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><present name="Think.get.id" >{$article.c2name}<else/>选择分类</present> <span class="caret"></span></button>
        <ul class="dropdown-menu">
            <foreach name="c2" item="vo">
                <li><a href="javascript:c2f({$vo.id},'{$vo.channel_name}')">{$vo.channel_name}</a></li>
            </foreach>
        </ul>
      </div><!-- /btn-group -->
      <input type="text" class="form-control selectInputC2" aria-label="...">
    </div><!-- /input-group -->
  </div><!-- /.col-lg-6 -->
  </div><!-- /.row -->
              </div>
              
              
              <div class="form-group">
              <label for="exampleInputEmail1">节日</label>
              <div class="row">
  <div class="col-lg-6">
    <div class="input-group">
      <div class="input-group-btn">
          <button type="button" class="btn btn-default dropdown-toggle selectC3" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><present name="Think.get.id" >{$article.c3name}<else/>选择分类</present> <span class="caret"></span></button>
        <ul class="dropdown-menu">
            <foreach name="c3" item="vo">
                <li><a href="javascript:c3f({$vo.id},'{$vo.channel_name}')">{$vo.channel_name}</a></li>
            </foreach>
        </ul>
      </div><!-- /btn-group -->
      <input type="text" class="form-control selectInputC3" aria-label="...">
    </div><!-- /input-group -->
  </div><!-- /.col-lg-6 -->
  </div><!-- /.row -->
              </div>
  
              
              <div class="form-group">
              <label for="exampleInputEmail1">文章类型</label>
              <div class="row">
  <div class="col-lg-6">
    <div class="input-group">
      <div class="input-group-btn">
          <button type="button" class="btn btn-default dropdown-toggle selectType" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><present name="Think.get.id" >{$article.value}<else/>选择类型</present> <span class="caret"></span></button>
        <ul class="dropdown-menu">
            <foreach name="type" item="vo">
                
                <li><a href="javascript:typeAction({$vo.id},'{$vo.value}')">{$vo.value}</a></li>
            </foreach>
        </ul>
      </div><!-- /btn-group -->
      <input type="text" class="form-control selectInputType" aria-label="...">
    </div><!-- /input-group -->
  </div><!-- /.col-lg-6 -->
  
</div><!-- /.row -->
              </div>
              
              <div class="form-group">
                
                  <textarea name="content" style="width:800px;height:400px;visibility:hidden;" id="content">
                      <present name="Think.get.id" >{$article.content}</present>
                  </textarea>
                  
              </div>
             
            <!--<div class="form-group">
              <label for="exampleInputPassword1">专业分类</label>
              <select class="form-control">
                <option>1</option>
                <option>2</option>
                <option>3</option>
                <option>4</option>
                <option>5</option>
              </select>
            </div>-->
              <present name="Think.get.id" >
                  <button type="submit" class="btn btn-default submit">修改</button>
                  <else/><button type="submit" class="btn btn-default submit">添加</button></present>
            
          </form>
          
        </div>
        <!--正式内容结束-->
      </div>
    </div>
        
        
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title" id="myModalLabel">提示</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer" style="display: none;">
        <button type="button" class="btn btn-default" data-dismiss="modal">知道了</button>
      </div>
    </div>
  </div>
</div>
        
    </body>
    <script>
        var editor;
        KindEditor.ready(function(K) {
                editor = K.create('textarea[name="content"]', {
                        allowFileManager : true
                });
                K('input[name=getHtml]').click(function(e) {
                        alert(editor.html());
                });
                K('input[name=isEmpty]').click(function(e) {
                        alert(editor.isEmpty());
                });
                K('input[name=getText]').click(function(e) {
                        alert(editor.text());
                });
                K('input[name=selectedHtml]').click(function(e) {
                        alert(editor.selectedHtml());
                });
                K('input[name=setHtml]').click(function(e) {
                        editor.html('<h3>Hello KindEditor</h3>');
                });
                K('input[name=setText]').click(function(e) {
                        editor.text('<h3>Hello KindEditor</h3>');
                });
                K('input[name=insertHtml]').click(function(e) {
                        editor.insertHtml('<strong>插入HTML</strong>');
                });
                K('input[name=appendHtml]').click(function(e) {
                        editor.appendHtml('<strong>添加HTML</strong>');
                });
                K('input[name=clear]').click(function(e) {
                        editor.html('');
                });




        });
                        
            
                        
//        $(".submit").click(function(){
////            console.log($("#txtEditor").Editor('getText'));
//            if (editor.text()=='') {
//                alert('请输入内容');
//                return;
//            }
//            if (channel==0) {
//                alert('请选择分类');
//                return;
//            }
//            if ($("input[name='title']").val()=='') {
//                alert('请输入标题');
//                return;
//            }
//            $.ajax({
//                cache: true,
//                type: "POST",
//                url:"?m=Center&c=Admin&a=article",
//                data:{'title':$("input[name='title']").val(),'channel':channel,'action':'add','content':document.getElementById('content').value},// 序列号formid
//                async: false,
//                dataType: 'json',
//                error: function(request) {
//                    $('.modal-body').html('提交超时，请稍候再试！');
//                    $('.modal-footer').css('display','block');
////                    $('#myModal').modal('hide');
//                },
//                success: function(data) {
//                    console.log(data);
//                    if (data.error == 0) {
////                        $('.modal-body').html('添加成功！');
//                        alert('添加成功！');
//                        window.location.href="?m=Center&c=Admin&a=article";
//                    }else{
//                        $('.modal-body').html(data.msg);
//                    }
//                },
//                beforeSend: function(){
//                    $('#myModal').modal('show');
//                    $('.modal-body').html('加载中！');
//                    $('.modal-footer').css('display','none');
//                },
//               complete: function(){
////                   $('#myModal').modal('hide');
//                    $('.modal-footer').css('display','block');
//                }
//            });
//        });
        var c1 = 0;
        function c1f($id,$value){
            c1 = $id;
            $("input[name='c1']").val(c1);
            $('.selectC1').html($value);
            $('.selectInputC1').val($value);
        }
        <present name="Think.get.id" >c1 = {$article.c1}; $("input[name='c1']").val({$article.c1});</present>

        var c2 = 0;
        function c2f($id,$value){
            c2 = $id;
            $("input[name='c2']").val(c2);
            $('.selectC2').html($value);
            $('.selectInputC2').val($value);
        }
        <present name="Think.get.id" >c2 = {$article.c2}; $("input[name='c2']").val({$article.c2});</present>

        var c3 = 0;
        function c3f($id,$value){
            c3 = $id;
            $("input[name='c3']").val(c3);
            $('.selectC3').html($value);
            $('.selectInputC3').val($value);
        }
        <present name="Think.get.id" >c3 = {$article.c3}; $("input[name='c3']").val({$article.c3});</present>

        var type = 0;
        function typeAction($id,$value){
            type = $id;
            $("input[name='type']").val(type);
            $('.selectType').html($value);
            $('.selectInputType').val($value);
//            alert($("input[name='type']").val());
        }
        <present name="Think.get.id" >type = {$article.type}; $("input[name='type']").val({$article.type});</present>
        
    </script>
</html>
